/**
 * 实现promiseAll
 * @param {*} promiseList 
 */
function myPromiseAll(promiseList) {
    const result = []
    return new Promise((resolve, reject) => {
        function addResult(response, index) {
            result[index] = response
            if (result.length === promiseList.length) {
                resolve(result)
            }
        }
        promiseList.forEach((p, index) => {
            if (p instanceof Promise) {
                Promise.resolve(p).then(response => {
                    addResult(response,index)
                    result[index] = response
                    
                }).catch(error => {
                    reject(error)
                })
            } else {
                addResult(p, index)
            }
        })
    })
    
}